<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 父子传值 -->
    <!-- 父组件app -->
    <div id="app">
        <demo title="hhhh" @myevent="handleMyEvent"></demo>

    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script>
        Vue.component("demo",{
            // props接收title传进来的值
            props:{
                title:String,
            },
            template:`
                <div>
                    <h1>子组件{{title}}</h1>
                    <button @click="handleClick">向父传值</button>
                </div>
            `,
            methods:{
                handleClick:function(){
                    this.$emit("myevent","zzzz");
                }

            }

        })
        let vm=new Vue({
            el:"#app",
            methods:{
                handleMyEvent:function(msg){
                    alert(msg);
                }
            }
        })







    </script>
</body>
</html>